
/*
本地离线促销3.0
 */
import 'package:reabampos/src/reabam/operation/bean/request_cuxiao.dart';
import 'package:reabampos/src/reabam/operation/db/objectbox.dart';
import 'package:reabampos/src/reabam/ui/pagestate_main_webview.dart';
import 'package:xsdk_flutter/xsdk/xsdk_flutter_package.dart';

class SupportOfflineCuxiao {

  MainWebViewStatePage statePage;

  SupportOfflineCuxiao(this.statePage);

  //////////////////////////////////////////////////////

  void getShoppingCartItemsPromotionPlanIds(dynamic data){

    RequestShoppingCartItemPromotionPlanIds beanH5UploadOrderTask;
    if(data is String){
      beanH5UploadOrderTask=RequestShoppingCartItemPromotionPlanIds.fromJson(XJsonUtils.json2Map(data));
    }else{
      beanH5UploadOrderTask=RequestShoppingCartItemPromotionPlanIds.fromJson(data??{});
    }

    //
    XObjectBoxUtils.getShoppingCartItemsPromotionPlanIds(beanH5UploadOrderTask,(Map<String,dynamic> result){
      String json=XJsonUtils.obj2Json(result);
      statePage.runJSFunction(statePage.jsFunction_getAppValue('getShoppingCartItemsPromotionPlanIds',json));
    });
  }
  void getShoppingCartItemsPromotionJsons(dynamic data){

    List<dynamic> ll;
    if(data is String){
      ll=XJsonUtils.json2List(data);
    }else{
      ll=data??[];
    }

    List<String> planIds=[];
    for(dynamic item in ll){
      planIds.add('$item');
    }
    //
    XObjectBoxUtils.getShoppingCartItemsPromotionJsons(planIds,(Map<String,dynamic> result){
      String json=XJsonUtils.obj2Json(result);
      statePage.runJSFunction(statePage.jsFunction_getAppValue('getShoppingCartItemsPromotionJsons',json));
    });
  }
  void getShoppingCartItemTimedPromotions(dynamic data){

    RequestShoppingCartItemTimedPromotion requestPromotion;
    if(data is String){
      requestPromotion=RequestShoppingCartItemTimedPromotion.fromJson(XJsonUtils.json2Map(data));
    }else{
      requestPromotion=RequestShoppingCartItemTimedPromotion.fromJson(data??{});
    }

    //
    XObjectBoxUtils.getShoppingCartItemTimedPromotions(requestPromotion,(Map<String,dynamic> result){
      String json=XJsonUtils.obj2Json(result);
      statePage.runJSFunction(statePage.jsFunction_getAppValue('getShoppingCartItemTimedPromotions',json));
    });
  }
  void getMutexPlans(dynamic data){

    RequestOrderMutexPlans requestPromotion;
    if(data is String){
      requestPromotion=RequestOrderMutexPlans.fromJson(XJsonUtils.json2Map(data));
    }else{
      requestPromotion=RequestOrderMutexPlans.fromJson(data??{});
    }

    //
    XObjectBoxUtils.getMutexPlans(requestPromotion,(Map<String,dynamic> result){
      String json=XJsonUtils.obj2Json(result);
      statePage.runJSFunction(statePage.jsFunction_getAppValue('getMutexPlans',json));
    });
  }
  void getShoppingCartItemListPromotions(dynamic data){

    RequestShoppingCartItemListPromotion requestPromotion;
    if(data is String){
      requestPromotion=RequestShoppingCartItemListPromotion.fromJson(XJsonUtils.json2Map(data));
    }else{
      requestPromotion=RequestShoppingCartItemListPromotion.fromJson(data??{});
    }

    //
    XObjectBoxUtils.getShoppingCartItemListPromotions(requestPromotion,(Map<String,dynamic> result){
      String json=XJsonUtils.obj2Json(result);
      statePage.runJSFunction(statePage.jsFunction_getAppValue('getShoppingCartItemListPromotions',json));
    });
  }
  void getOrderItemsPromotionSpecIds(dynamic data){

    RequestOrderItemPromotion requestPromotion;
    if(data is String){
      requestPromotion=RequestOrderItemPromotion.fromJson(XJsonUtils.json2Map(data));
    }else{
      requestPromotion=RequestOrderItemPromotion.fromJson(data??{});
    }

    //
    XObjectBoxUtils.getOrderItemsPromotionSpecIds(requestPromotion,(Map<String,dynamic> result){
      String json=XJsonUtils.obj2Json(result);
      statePage.runJSFunction(statePage.jsFunction_getAppValue('getOrderItemsPromotionSpecIds',json));
    });
  }
  void getOrderPromotions(){
    //
    XObjectBoxUtils.getOrderPromotions((Map<String,dynamic> result){
      String json=XJsonUtils.obj2Json(result);
      statePage.runJSFunction(statePage.jsFunction_getAppValue('getOrderPromotions',json));
    });
  }




}